import { useSelector } from "react-redux"
import { selectAuthorById } from "./authorsSlice"

export const PostAuthor = ({authorId}) => {
  const author = useSelector(state => selectAuthorById(state, authorId))

  return <span>by {author ? author.name : 'Unknow author'}</span>
}